package com.shzq.service.impl;

import com.shzq.dao.UserDao;
import com.shzq.pojo.UserDO;
import com.shzq.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCrypt;
import org.springframework.stereotype.Service;

/**
 * @author zml
 * time: 2020/5/7 16:16
 * mailbox  zmlelselove@126.com
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public void add(UserDO user) {
        String password = BCrypt.hashpw(user.getPassword(), BCrypt.gensalt());
        user.setPassword(password);
        userDao.insert(user);
    }

    @Override
    public UserDO getByUsername(String username) {
        return userDao.selectByPrimaryKey(username);
    }
}
